package com.sto.stoapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sto.stoapp.activity.R;

import java.util.List;

/**
 * Created by wj on 2016-12-05.
 */

public class SalesSignNamesAdapter extends BaseAdapter{

    private Context context;
    private List<String> names;

    public SalesSignNamesAdapter(Context context, List<String> names) {
        this.context = context;
        this.names = names;
    }

    @Override
    public int getCount() {
        return names.size();
    }

    @Override
    public String getItem(int position) {
        return names.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Holder holder;
        if(convertView==null){
            holder=new Holder();
            convertView= LayoutInflater.from(context).
                    inflate(R.layout.item_select_names,null);
            holder.numTV= (TextView) convertView.findViewById(R.id.tv_num);
            holder.nameTV= (TextView) convertView.findViewById(R.id.tv_name);
            convertView.setTag(holder);
        }else {
            holder= (Holder) convertView.getTag();
        }

        holder.numTV.setText(position+1+"");
        holder.nameTV.setText(getItem(position));

        return convertView;
    }

    class Holder{
        TextView numTV,nameTV;
    }
}
